<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // 
        // const arr = [1];
        // // arr.index = 1;    // 自定义属性
        // arr.noRepeat = function () {    // 自定义方法   
        //     console.log(333);
        // }


        // const arr2 = [1, 2];
        // console.log(arr2.index);
        // arr2.noRepeat()




        // arr   Array

        // 提供共有属性和方法
        Array.prototype.index = 6;


        const arr = [1];
        console.log(arr.index);




        Array.prototype.noRepeat = function () {
            const arr2 = [];
            // this指向这个实例化对象
            this.forEach(v => {
                if (!arr2.includes(v)) {
                    arr2.push(v)
                }
            })
            return arr2
        }




        const arr3 = [1, 3, 2, 1, 2, 4, 35];

        const res = arr3.noRepeat();

        console.log(res);





        // 日期对象   format
        Date.prototype.format = function () {
            const y = this.getFullYear();
            const m = this.getMonth() + 1;
            const d = this.getDate();


            return y + '-' + m + '-' + d
        }




        const d = new Date();

        console.log(d.format())



    </script>

</body>

</html>